/**
 * Created by dale on 2017/10/9.
 */
var useCarList;
$(document).ready(function () {
    useCarList = $('#useCarList');
    $('.xh-datagrid-toolbar').parseToolbar();
    var iCarId = addressUri.getParam('iCarId');
    useCarList.initDataGrid(baseUrl + 'lm/car/getUseCar/read',{queryParams:{iCarId:iCarId}}).setSelectThenEnable(['bt_list_del'],['bt_list_startUse','bt_list_endUse']);

    $('#bt_list_startUse').click(function () {
        if(xhExtra.buttonDisabled($(this))){ return false }
        var iUCId = useCarList.getDataGridSelectedField('iUCId');
        if(iUCId==null){
            window.top.swal(
                '',
                '未找到关联用车记录',
                'error'
            );
            return false;
        }
        xhTop.showModal({
            id:'confirmModel',
            title:'取车确认',
            content: '<iframe src="'+baseUrl+'lm/car/confirm/'+iUCId+'/1"  style="width: 100%;;border-style: none;padding: 0px;height:250px"  scrolling="yes"   ></iframe>',
            button:'提交'
        });
    });

    $('#bt_list_endUse').click(function () {
        if(xhExtra.buttonDisabled($(this))){ return false }
        var iUCId = useCarList.getDataGridSelectedField('iUCId');
        if(iUCId==null){
            window.top.swal(
                '',
                '未找到关联用车记录',
                'error'
            );
            return false;
        }
        xhTop.showModal({
            id:'confirmModel',
            title:'还车确认',
            content: '<iframe src="'+baseUrl+'lm/car/confirm/'+iUCId+'/2"  style="width: 100%;;border-style: none;padding: 0px;height:250px"  scrolling="yes"   ></iframe>',
            button:'提交'
        });
    });

});
